﻿using jinmaMesProxy.Excep;
using jinmaMesProxy.Model;
using jinmaMesProxy.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;

namespace jinmaMesProxy.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MaterialController : MyController
    {
        MaterialService materialService = new MaterialService();
        StockService stockService = new StockService();
        [HttpPost, Authorize]
        public ResponseData<Material> List(dynamic data)
        {
            string d = data.update_time;
            if (String.IsNullOrWhiteSpace(d))
                throw new MyException("请提供update_time参数");
            return new ResponseData<Material>(materialService.List(d));
        }
        [HttpPost, Authorize]
        public ResponseData<StockInfo> GetQty(dynamic data)
        {
            string[] d = data.materials.ToObject<string[]>();
            return new ResponseData<StockInfo>(stockService.GetQty(d));
        }
    }
}
